package Interview;

public class Test {

	public static long function(int x,int n){
		long sum = 0;
		for (int i = 0; i < n+1; i++) {
			sum+=Math.pow(x,i);
		}
		return sum;
	}
	
	public static void main(String[] args) {
System.out.println(function(3, 3));
	
}
}

